*************************
**** P A N E L  A *******
*************************
clear all
set more off
cd "/Users/yasenov/Dropbox/mariel_boatlift/jhr_version/jhr_figures"
global folder /Users/yasenov/Dropbox/mariel_boatlift/revision_version/revision_data/
use $folder/aux_nonevent.dta

keep if age >= 19
keep if unemp != .
keep if black == 1 
drop if ftpt79 == 0 | ftpt89 == 1 | ftpt94 == 1
drop if classer > 2 & classer != . & year <= 1993
drop if class94 > 4 & class94 !=. & year >= 1994

sort msafips year // delete msafipss with too few observations
by msafips year: gen sum_year = _N
by msafips: egen min_year = min(sum_year)
drop if min_year < 30		// # min obs per msafips-year
drop sum_year min_year

collapse (mean) unemp [pw=earnwt], by(year msafips)

merge 1:1 msafips year using $folder/msa_controls_nonevent, nogenerate
drop if unemp == .

sort msafips year
by msafips: gen num_year = _N
tab num_year
keep if num_year >= 14 
keep if year > 1988
xtset msafips year
label drop _all

global controls unemp(1993) low_skilled hisp manuf
synth unemp $controls, trunit(5000) trperiod(1994) nested keep(fig_a2a.dta, replace)

use fig_a2a.dta, clear
rename (_time _Y_t _Y_s) (year miami synthetic)
keep year miami synthetic
keep if year != .

twoway (line miami year, lcolor(black) lpattern(solid)) ///
	(line synthetic year, lcolor(black) lpattern(dash)), ///
	xtitle("") ///
	xline(1993, lcolor(black) lpattern(dash)) ///
	legend(label(1 "Miami") label(2 "Synthetic Miami")) ///
	subtitle("African-American") ///
	xlabel(1989 "1989" 1991 "91" 1993 `""93" "Pre""' 1995 `""95" "Post""' 1997 "97" 1999 "99" 2001 "01") ///
	xscale(range(1989 2002)) ///
	ylabel(.01(.02).15) ///
	text(.15 2001 "Panel A") plotregion(lwidth(none))

graph export "jhr_figa2a.pdf", replace

*************************
**** P A N E L  B *******
*************************
clear
set more off
use $folder/aux_nonevent.dta

keep if age >= 19
keep if unemp != .
keep if ethnic != 5 & ethnic != 8 
drop if ftpt79 == 0 | ftpt89 == 1 | ftpt94 == 1
drop if classer > 2 & classer != . & year <= 1993
drop if class94 > 4 & class94 !=. & year >= 1994

sort msafips year // delete msafipss with too few observations
by msafips year: gen sum_year = _N
by msafips: egen min_year = min(sum_year)
drop if min_year < 30		// # min obs per msafips-year
drop sum_year min_year

collapse (mean) unemp [pw=earnwt], by(year msafips)

merge 1:1 msafips year using $folder/msa_controls_nonevent, nogenerate
drop if unemp == .

sort msafips year
by msafips: gen num_year = _N
tab num_year
keep if num_year >= 14 
keep if year > 1988
xtset msafips year
label drop _all

global controls unemp low_skilled hisp manuf
synth unemp $controls, trunit(5000) trperiod(1994) nested keep(fig_a2b.dta, replace)

use fig_a2b.dta, clear
rename (_time _Y_t _Y_s) (year miami synthetic)
keep year miami synthetic
keep if year != .

twoway (line miami year, lcolor(black) lpattern(solid)) ///
	(line synthetic year, lcolor(black) lpattern(dash)), ///
	xtitle("") ///
	xline(1993, lcolor(black) lpattern(dash)) ///
	legend(label(1 "Miami") label(2 "Synthetic Miami")) ///
	subtitle("Non-Cuban Hispanics") ///
	xlabel(1989 "89" 1991 "91" 1993 `""93" "Pre""' 1995 `""95" "Post""' 1997 "97" 1999 "99" 2001 "01") ///
	xscale(range(1989 2002)) ///
	ylabel(.01(.02).15) ///
	text(.15 2001 "Panel B") plotregion(lwidth(none))
	
graph copy two, replace
graph export "jhr_figa2b.pdf", replace
